import Cookies from 'js-cookie'

const TokenKey = 'token'
// 通过 Cookie 存储令牌token
export function getSotrageToken() {
    return Cookies.get(TokenKey)
}

export function setStorageToken(token) {
    return Cookies.set(TokenKey, token)
}

export function removeStorageToken() {
    return Cookies.remove(TokenKey)
}

const UserKey = 'user'  //键
//用户数据保存在 LocalStorage
export function getStorageUser() {
    let user = localStorage.getItem(UserKey)
    return user ? JSON.parse(user) : {}
}

export function setStorageUser(user) {
    return localStorage.setItem(UserKey, JSON.stringify(user))
}

export function removeStorageUser() {
    return localStorage.removeItem(UserKey)
}